'''
@Author: your name
@Date: 2020-03-02 10:08:59
@LastEditTime: 2020-03-02 10:23:59
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: /permcomp/permcomp/settings/product.py
'''
import os
import logging
import pymysql
import django
from datetime import datetime

from .base import * # NOQA


pymysql.install_as_MySQLdb()

DEBUG = True

DATABASES = {
    'default' : {
        'ENGINE':   'django.db.backends.mysql',
        'NAME':     'xmlviewer',
        'USER':     'root',
        'PASSWORD': '654321',
        'HOST':     '',
        'PORT':     '',
    }
}

LOGGING_DIR = os.path.join(BASE_DIR, "logs")
if not os.path.exists(LOGGING_DIR):
    os.mkdir(LOGGING_DIR)


LOG_FILE_NAME = "permcomp_{}.log".format(datetime.now().strftime("%Y_%m_%d"))


LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'standard': {
            'format': '[%(levelname)s][%(asctime)s][%(filename)s][%(funcName)s][%(lineno)d] > %(message)s'
        },
        'simple': {
            'format': '[%(levelname)s]> %(message)s'
        },
    },
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'file_handler': {
            'level': 'DEBUG',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'filename': os.path.join(LOGGING_DIR, LOG_FILE_NAME),
            'formatter':'standard'
        }
    },
    'loggers': {
        'comparison': {
            'handlers': ['console','file_handler'],
            'level':'DEBUG',  
            'propagate': True,
        }
    }
}


